Skip to content

Conversation

@nochinxx
Copy link
Collaborator

@nochinxx nochinxx commented Nov 18, 2025

This PR fixes how add_vline() handles annotations, addressing the bug described in #3065
where add_vline(x=, annotation_text=...) caused a TypeError.
It refactors the logic to use the new shape.label attribute instead of creating a separate annotation, which removes the arithmetic step that caused the failure.

Why this change
Previously, add_vline created both a shape and an annotation to display text.
To position the annotation, it computed the mean/min/max of the line’s coordinates — which broke for mixed data types (e.g., strings + datetimes).
Using shape.label removes that calculation entirely and simplifies the API.

What’s included

Added helper _coerce_shape_label_from_legacy_annotation_kwargs(kwargs)

  • Safely maps legacy annotation_* kwargs (text, font, textangle) into a shape.label dict, emitting a FutureWarning.

Added _normalize_legacy_line_position_to_textposition()

  • Maps legacy annotation_position to "start" | "middle" | "end".

Updated _process_multiple_axis_spanning_shapes()

  • For vline, creates a single labeled shape (label.textposition maps: top→end, bottom→start, middle→middle).
  • Skips creating a layout.annotation

Feedback

@nochinxx nochinxx changed the title Refactor/autoshapes use shape label, vline: switch to shape.label (no separate annotation) + legacy shim Fixes error in vline related to shape label instead of annotations Nov 19, 2025
@nochinxx nochinxx merged commit b21ed6e into main Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants